﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using DXApplicationTangche.service;
using DXApplicationTangche.UC.款式尺寸;
using mendian;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.货号管理.service
{
    public class 款式迭代Service
    {
        /// <summary>
        /// 根据工序及款式获取工序可见设计
        /// </summary>
        /// <param name="projectInstanceCode"></param>
        /// <param name="styleNameCn"></param>
        /// <param name="isSeller"></param>
        /// <returns></returns>
        public static List<CraftDesignStyleRelationDTO> getProjectCraftByProjectCodeAndStyleNameCn(
            String projectInstanceCode,
            String styleNameCn,
            Boolean isSeller
            )
        {
            try
            {
                return
                    FunctionHelper.JsonDeserialization<List<CraftDesignStyleRelationDTO>>(
                        RestCall.httpGetMethod(
                            URL.接口url + "/recipe/getProjectCraftByProjectCodeAndStyleNameCn?projectInstanceCode=" + projectInstanceCode
                                + "&styleNameCn=" + styleNameCn
                                + "&isSeller=" + isSeller
                            )
                        );
            }
            catch (Exception)
            {
                return new List<CraftDesignStyleRelationDTO>();
            }

        }
        /// <summary>
        /// 查询款式下的款式及销量一览
        /// </summary>
        /// <param name="styleId"></param>
        /// <returns></returns>
        public static List<styleSaleCountDTO> getSaleCountByStyleNameCn(String styleId)
        {
            List<styleSaleCountDTO> styleSaleCountDTOs = new List<styleSaleCountDTO>();
            Dictionary<String, int> keyValuePairs =
                FunctionHelper.JsonDeserialization<Dictionary<String, int>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/sale_style/getSaleCountByStyleNameCn?saleStyleCode=" + styleId
                        )
                    );
            if (keyValuePairs != null && keyValuePairs.Count != 0)
            {
                foreach (KeyValuePair<String, int> keyValuePair in keyValuePairs)
                {
                    styleSaleCountDTOs.Add(new styleSaleCountDTO(keyValuePair));
                }
            }
            return styleSaleCountDTOs;
        }

        /// <summary>
        /// 查询款式下不同工艺的的设计点
        /// </summary>
        /// <param name="craftType"></param>
        /// <param name="styleCode"></param>
        /// <returns></returns>
        public static List<CraftDesignStyleRelationDTO> getCraftStyleDesignDTOs(String craftType, String styleCode)
        {
            return
                FunctionHelper.JsonDeserialization<List<CraftDesignStyleRelationDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/recipe/getCraftStyleDesignDTOs?craftType=" + craftType + "&styleCode=" + styleCode
                        )
                    );
        }

        /// <summary>
        /// 将款式下设计的生效结果保存到数据库  
        /// </summary>
        /// <param name="craftDesignStyleRelationDTOs"></param>
        /// <returns></returns>
        public static String saveCraftFacadeStyleDesignDB(List<CraftDesignStyleRelationDTO> craftDesignStyleRelationDTOs)
        {
            return
                RestCall.PostHttp(
                    URL.接口url + "/recipe/saveCraftFacadeStyleDesignDB",
                    FunctionHelper.JsonSerialization(craftDesignStyleRelationDTOs)
                );
        }
        /// <summary>
        /// 删除款式下的设计点
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static String deleteCraftFacadeStyleDesignDBById(String id)
        {
            return
                RestCall.httpGetMethod(
                    URL.接口url + "/recipe/deleteCraftFacadeStyleDesignDBById?id=" + id
                );
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="styleSonCode"></param>
        /// <returns></returns>
        public static List<DTO尺寸> getSizeListByStyleNameCn(String styleSonCode)
        {
            return
                FunctionHelper.JsonDeserialization<List<DTO尺寸>>(
                        RestCall.httpGetMethod(
                            URL.接口url + "/size/findByStyleNameCn?styleNameCn=" + styleSonCode
                            )
                        );
        }

        /// <summary>
        /// 导出款式设计点到excel
        /// </summary>
        /// <param name="craftDesignStyleRelationDTOs"></param>
        public static void exportDataToExcelFile(List<CraftDesignStyleRelationDTO> craftDesignStyleRelationDTOs)
        {
            System.Windows.Forms.FolderBrowserDialog sFD = new System.Windows.Forms.FolderBrowserDialog();
            System.Windows.Forms.DialogResult rdr = sFD.ShowDialog();
            string filePath = sFD.SelectedPath;
            XSSFWorkbook workbook = new XSSFWorkbook();
            ISheet sheet = null;
            filePath = filePath + "\\" + DateTime.Now.ToString("yyyy年MM月dd日HH时mm分") + "款式工艺设计点一览.xlsx";
            FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            int i = 0;
            try
            {
                sheet = workbook.CreateSheet(DateTime.Now.ToString("yyyy年MM月dd日HH时mm分") + "款式工艺设计点");
                IRow rowTitle = sheet.CreateRow(0);
                rowTitle.CreateCell(0).SetCellValue("id");
                rowTitle.CreateCell(1).SetCellValue("工艺类别");
                rowTitle.CreateCell(2).SetCellValue("款号");
                rowTitle.CreateCell(3).SetCellValue("位置id");
                rowTitle.CreateCell(4).SetCellValue("位置描述");
                rowTitle.CreateCell(5).SetCellValue("工艺设计id");
                rowTitle.CreateCell(6).SetCellValue("工艺设计编码");
                rowTitle.CreateCell(7).SetCellValue("工艺设计描述");
                rowTitle.CreateCell(8).SetCellValue("审版");
                rowTitle.CreateCell(9).SetCellValue("调版");
                rowTitle.CreateCell(10).SetCellValue("裁断");
                rowTitle.CreateCell(11).SetCellValue("粘衬");
                rowTitle.CreateCell(12).SetCellValue("车间");
                rowTitle.CreateCell(13).SetCellValue("半成手缝");
                rowTitle.CreateCell(14).SetCellValue("特种");
                rowTitle.CreateCell(15).SetCellValue("成品手缝");
                rowTitle.CreateCell(16).SetCellValue("检查");
                rowTitle.CreateCell(17).SetCellValue("销售");
                for (i = 0; i < craftDesignStyleRelationDTOs.Count; i++)
                {
                    IRow rowTitle1 = sheet.CreateRow(i + 1);
                    rowTitle1.CreateCell(0).SetCellValue(craftDesignStyleRelationDTOs[i].id);
                    rowTitle1.CreateCell(1).SetCellValue(craftDesignStyleRelationDTOs[i].craftType);
                    rowTitle1.CreateCell(2).SetCellValue(craftDesignStyleRelationDTOs[i].styleCode);
                    rowTitle1.CreateCell(3).SetCellValue(craftDesignStyleRelationDTOs[i].partId);
                    rowTitle1.CreateCell(4).SetCellValue(craftDesignStyleRelationDTOs[i].partDesc);
                    rowTitle1.CreateCell(5).SetCellValue(craftDesignStyleRelationDTOs[i].craftDesignId);
                    rowTitle1.CreateCell(6).SetCellValue(craftDesignStyleRelationDTOs[i].craftDesignCode);
                    rowTitle1.CreateCell(7).SetCellValue(craftDesignStyleRelationDTOs[i].craftDesignDesc);
                    rowTitle1.CreateCell(8).SetCellValue(craftDesignStyleRelationDTOs[i].reviewEdition);
                    rowTitle1.CreateCell(9).SetCellValue(craftDesignStyleRelationDTOs[i].adjustEdition);
                    rowTitle1.CreateCell(10).SetCellValue(craftDesignStyleRelationDTOs[i].tailoring);
                    rowTitle1.CreateCell(11).SetCellValue(craftDesignStyleRelationDTOs[i].adhesive);
                    rowTitle1.CreateCell(12).SetCellValue(craftDesignStyleRelationDTOs[i].workShop);
                    rowTitle1.CreateCell(13).SetCellValue(craftDesignStyleRelationDTOs[i].halfSewing);
                    rowTitle1.CreateCell(14).SetCellValue(craftDesignStyleRelationDTOs[i].specialType);
                    rowTitle1.CreateCell(15).SetCellValue(craftDesignStyleRelationDTOs[i].finishedSewing);
                    rowTitle1.CreateCell(16).SetCellValue(craftDesignStyleRelationDTOs[i].checkUp);
                    rowTitle1.CreateCell(17).SetCellValue(craftDesignStyleRelationDTOs[i].seller);
                }
                workbook.Write(fileStream); //写入到excel
                workbook.Close();
            }
            catch (Exception ex)
            {

            }
        }
        /// <summary>
        /// 导入款式工艺设计点
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="styleSonCode"></param>
        /// <returns></returns>
        public static List<CraftDesignStyleRelationDTO> importDataFromExcelFile(DataTable dataTable, String styleSonCode)
        {
            List<CraftDesignStyleRelationDTO> craftDesignStyleRelationDTOs = new List<CraftDesignStyleRelationDTO>();
            foreach (DataRow dataRow in dataTable.Rows)
            {
                if (dataRow.Equals(dataTable.Rows[0]))
                {
                    //  去掉第一行
                    continue;
                }
                else
                {
                    craftDesignStyleRelationDTOs.Add(
                            new CraftDesignStyleRelationDTO(
                                dataRow["Column1"].ToString().Replace("\r", "").Replace("\n", "").Trim(),
                                styleSonCode.Trim(),
                                dataRow["Column3"].ToString().Replace("\r", "").Replace("\n", "").Trim(),
                                dataRow["Column4"].ToString().Replace("\r", "").Replace("\n", "").Trim(),
                                dataRow["Column5"].ToString().Replace("\r", "").Replace("\n", "").Trim(),
                                dataRow["Column6"].ToString().Replace("\r", "").Replace("\n", "").Trim(),
                                dataRow["Column7"].ToString().Replace("\r", "").Replace("\n", "").Trim(),
                                Convert.ToBoolean(dataRow["Column8"].ToString().Replace("\r", "").Replace("\n", "").Trim()),
                                Convert.ToBoolean(dataRow["Column9"].ToString().Replace("\r", "").Replace("\n", "").Trim()),
                                Convert.ToBoolean(dataRow["Column10"].ToString().Replace("\r", "").Replace("\n", "").Trim()),
                                Convert.ToBoolean(dataRow["Column11"].ToString().Replace("\r", "").Replace("\n", "").Trim()),
                                Convert.ToBoolean(dataRow["Column12"].ToString().Replace("\r", "").Replace("\n", "").Trim()),
                                Convert.ToBoolean(dataRow["Column13"].ToString().Replace("\r", "").Replace("\n", "").Trim()),
                                Convert.ToBoolean(dataRow["Column14"].ToString().Replace("\r", "").Replace("\n", "").Trim()),
                                Convert.ToBoolean(dataRow["Column15"].ToString().Replace("\r", "").Replace("\n", "").Trim()),
                                Convert.ToBoolean(dataRow["Column16"].ToString().Replace("\r", "").Replace("\n", "").Trim()),
                                Convert.ToBoolean(dataRow["Column17"].ToString().Replace("\r", "").Replace("\n", "").Trim())
                                )
                            ); ;
                }
            }
            return craftDesignStyleRelationDTOs;
        }
        /// <summary>
        /// 取得位置一览
        /// </summary>
        /// <returns></returns>
        public static List<GarmentPartDTO> getAllGarmentPartDaos()
        {
            return
                FunctionHelper.JsonDeserialization<List<GarmentPartDTO>>(
                    RestCall.httpGetMethod(URL.接口url + "/recipe/getAllGarmentPartDaos")
                );
        }

        /// <summary>
        /// 根据标准款id查询其他款式设计点，用来批量同步其他款式设计点
        /// </summary>
        /// <param name="saleStyleCode"></param>
        /// <returns></returns>
        public static Dictionary<String, List<CraftDesignStyleRelationDTO>> getCraftDesignStyleRelationGroupBySaleStyleCode(String saleStyleCode)
        {
            return
                FunctionHelper.JsonDeserialization<Dictionary<String, List<CraftDesignStyleRelationDTO>>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/recipe/getCraftDesignStyleRelationGroupBySaleStyleCode?saleStyleCode=" + saleStyleCode
                        )
                    );
        }
        /// <summary>
        /// 根据标准款id查询其他款式工艺设计
        /// 1.可选设计点
        /// 2.参考工艺设计，改一改直接用
        /// </summary>
        /// <param name="saleStyleCode"></param>
        /// <returns></returns>
        public static Dictionary<String, CraftDesignStyleRelationDTO> getCraftDesignBySaleStyleCode(String saleStyleCode)
        {
            return
                FunctionHelper.JsonDeserialization<Dictionary<String, CraftDesignStyleRelationDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/recipe/getCraftDesignBySaleStyleCode?saleStyleCode=" + saleStyleCode
                        )
                    );
        }

        #region 外观设计点
        /// <summary>
        /// 新建外观设计点知识库
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="itemCd"></param>
        /// <param name="itemTypeName"></param>
        /// <param name="itemValue"></param>
        /// <param name="itemNameCn"></param>
        /// <returns></returns>
        public static String saveCraftFacadeDesign(
            String sessionId,
            String itemCd,
            String itemTypeName,
            String itemValue,
            String itemNameCn
            )
        {
            return
                RestCall.httpGetMethod(
                        URL.接口url + "/recipe/saveCraftFacadeDesign"
                        + "?sessionId=" + sessionId
                        + "&itemCd=" + itemCd
                        + "&itemTypeName=" + itemTypeName
                        + "&itemValue=" + itemValue
                        + "&itemNameCn=" + itemNameCn
                    );
        }
        /// <summary>
        /// 保存ai图
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="ofd"></param>
        public static String saveCraftFacadeDesinFile(
            String sessionId,
            String fileName
            )
        {
            return
                FileService.UploadRequest(
                    URL.接口url + "/recipe/saveCraftFacadeDesinFile?sessionId=" + sessionId,
                    fileName,
                    Path.GetFileName(fileName),
                    "multipartFile"
                    );
        }

        /// <summary>
        /// 根据外观设计点id取得dto
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static CraftFacadeDesignDTO getCraftFacadeDesignDTO(String id)
        {
            return FunctionHelper.JsonDeserialization<CraftFacadeDesignDTO>(
                RestCall.httpGetMethod(
                    URL.接口url + "/recipe/getCraftFacadeDesignDTO?id=" + id
                    )
                );
        }
        /// <summary>
        /// 保存款式下的外观设计点
        /// </summary>
        /// <param name="styleCode"></param>
        /// <param name="craftFacadeStyleDesignIdAndDesignIdMap"></param>
        /// <returns></returns>
        public static String saveCraftFacadeStyleDesign(
            String styleCode,
            Dictionary<String, String> craftFacadeStyleDesignIdAndDesignIdMap)
        {
            return
                RestCall.PostHttp(
                        URL.接口url + "/recipe/saveCraftFacadeStyleDesign?styleCode=" + styleCode,
                        FunctionHelper.JsonSerialization(craftFacadeStyleDesignIdAndDesignIdMap)
                        );
        }
        /// <summary>
        /// 取待上传设计点在知识库中的映射关系
        /// </summary>
        /// <param name="facadeValues"></param>
        /// <returns></returns>
        public static CraftFacadeDesignImportDTO getCraftFacadeDesignImportInfo(List<String> facadeValues)
        {
            return
                FunctionHelper.JsonDeserialization<CraftFacadeDesignImportDTO>(
                    RestCall.PostHttp(
                        URL.接口url + "/recipe/getCraftFacadeDesignImportInfo",
                        FunctionHelper.JsonSerialization(facadeValues)
                        )
                );
        }
        /// <summary>
        /// 款式下外观设计点ES
        /// </summary>
        /// <param name="styleCode"></param>
        /// <returns></returns>
        public static List<CraftDesignStyleRelationDTO> getCraftFacadeStyleDesignDao(String styleCode)
        {
            return
                FunctionHelper.JsonDeserialization<List<CraftDesignStyleRelationDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/recipe/getCraftFacadeStyleDesignDao?styleCode=" + styleCode
                        )
                );
        }
        #endregion

        #region 工艺设计点
        /// <summary>
        /// 保存工艺设计要求项
        /// </summary>
        /// <param name="craftDesignDTO"></param>
        /// <returns></returns>
        public static CraftDesignDTO saveCraftDesignDTO(CraftDesignDTO craftDesignDTO)
        {
            return
                FunctionHelper.JsonDeserialization<CraftDesignDTO>(
                    RestCall.PostHttp(
                        URL.接口url + "/recipe/saveCraftDesignDTO",
                        FunctionHelper.JsonSerialization(craftDesignDTO)
                        )
                    );
        }
        /// <summary>
        /// 查询所有工艺设计
        /// </summary>
        /// <returns></returns>
        public static List<CraftDesignDTO> getListCraftDesignDTOs()
        {
            return
                FunctionHelper.JsonDeserialization<List<CraftDesignDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/recipe/getListCraftDesignDTOs"
                        )
                    );
        }
        /// <summary>
        /// 根据id查询工艺设计
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static CraftDesignDTO getCraftDesignDTOById(String id)
        {
            return
                FunctionHelper.JsonDeserialization<CraftDesignDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/recipe/getCraftDesignDTOById?id=" + id
                        )
                    );
        }
        /// <summary>
        /// 保存款式下的工艺设计点
        /// </summary>
        /// <param name="id"></param>
        /// <param name="styleCode"></param>
        /// <param name="partId"></param>
        /// <param name="craftDesignId"></param>
        /// <returns></returns>
        public static String saveCraftDesignStyleRelation(
            String id,
            String styleCode,
            String partId,
            String craftDesignId)
        {
            return
                RestCall.httpGetMethod(
                    URL.接口url + "/recipe/saveCraftDesignStyleRelation?id=" + id
                                + "&styleCode=" + styleCode
                                + "&partId=" + partId
                                + "&craftDesignId=" + craftDesignId
                    );
        }
        /// <summary>
        /// 新建工艺设计点前的相似匹配
        /// </summary>
        /// <param name="desc"></param>
        /// <returns></returns>
        public static List<CraftDesignDTO> getRelevantCraftDesignDTOByDesc(String desc)
        {
            return
                FunctionHelper.JsonDeserialization<List<CraftDesignDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/recipe/getRelevantCraftDesignDTOByDesc?desc=" + desc
                        )
                    );
        }
        #endregion
    }
    /// <summary>
    /// 外观设计点文件
    /// </summary>
    public class CraftFacadeDesignImportDTO
    {
        public List<CraftFacadeDesignDTO> craftFacadeDesignDTOList { get; set; } = new List<CraftFacadeDesignDTO>();   //  知识库中的设计点
        public List<String> invalidFacadeValues { get; set; } = new List<String>();   //  知识库中没有包含的设计点
        public CraftFacadeDesignImportDTO()
        {

        }
    }
    /// <summary>
    /// 款式下设计DTO
    /// </summary>
    public class CraftDesignStyleRelationDTO
    {
        public String id { get; set; } //  id
        public String craftType { get; set; }//工艺类别 top.toptimus.constValue.CraftTypeConsts
        public String styleCode { get; set; }//  款号
        public String partId { get; set; } //  部位id
        public String partDesc { get; set; }   //  部位描述    top.toptimus.recipe.dao.GarmentPartDao.id
        public String craftDesignId { get; set; }  //  工艺设计要求项id  top.toptimus.recipe.dao.CraftDesignDao.id
        public String craftDesignCode { get; set; }   //  工艺设计要求项编码
        public String craftDesignDesc { get; set; }   //  工艺设计要求项描述
        public Boolean reviewEdition { get; set; }// 	审版
        public Boolean adjustEdition { get; set; } //	调版
        public Boolean tailoring { get; set; }       //	裁断
        public Boolean adhesive { get; set; }//	粘衬（案板）
        public Boolean workShop { get; set; }   //	车间（机台）
        public Boolean halfSewing { get; set; }// 	半成手缝（手缝）
        public Boolean specialType { get; set; }   //	特种（刺绣、钉锁）
        public Boolean finishedSewing { get; set; }   //	成品手缝（手缝）
        public Boolean checkUp { get; set; }   //	检查（成品质检）
        public Boolean seller { get; set; }// 销售
        public CraftDesignStyleRelationDTO()
        {

        }
        public CraftDesignStyleRelationDTO(CraftFacadeDesignDTO craft, String styleCode)
        {
            this.id = new FunctionHelper().Uuid;
            this.craftType = "外观设计";
            this.styleCode = styleCode;
            this.partId = craft.partId;
            this.partDesc = craft.partDesc;
            this.craftDesignId = craft.id;
            this.craftDesignCode = craft.facadeCode;
            this.craftDesignDesc = craft.facadeValue;
        }
        public CraftDesignStyleRelationDTO(String styleCode, CraftDesignDTO craftDesignDTO)
        {
            this.id = new FunctionHelper().Uuid;
            this.craftType = "工艺设计";
            this.styleCode = styleCode;
            this.craftDesignId = craftDesignDTO.id;
            this.craftDesignCode = craftDesignDTO.code;
            this.craftDesignDesc = craftDesignDTO.desc;
        }
        public CraftDesignStyleRelationDTO(string craftType, string styleCode, string partId, string partDesc, string craftDesignId, string craftDesignCode, string craftDesignDesc, bool reviewEdition, bool adjustEdition, bool tailoring, bool adhesive, bool workShop, bool halfSewing, bool specialType, bool finishedSewing, bool checkUp, bool seller)
        {
            this.id = new FunctionHelper().Uuid;
            this.craftType = craftType;
            this.styleCode = styleCode;
            this.partId = partId;
            this.partDesc = partDesc;
            this.craftDesignId = craftDesignId;
            this.craftDesignCode = craftDesignCode;
            this.craftDesignDesc = craftDesignDesc;
            this.reviewEdition = reviewEdition;
            this.adjustEdition = adjustEdition;
            this.tailoring = tailoring;
            this.adhesive = adhesive;
            this.workShop = workShop;
            this.halfSewing = halfSewing;
            this.specialType = specialType;
            this.finishedSewing = finishedSewing;
            this.checkUp = checkUp;
            this.seller = seller;
        }
    }
    /// <summary>
    /// 工艺类别Const
    /// </summary>
    public class CraftTypeConst
    {
        public const String APPEARANCE_DESIGN = "外观设计";//  外观设计
        public const String PROCESS_PLANNING = "工艺设计";//  工艺设计
    }
    /// <summary>
    /// 工艺设计点DTO
    /// </summary>
    public class CraftDesignDTO
    {
        public String id { get; set; }      //  id
        public String code { get; set; }   //  编码
        public String desc { get; set; }  //  工艺设计
        public String descPinyin { get; set; }  //  工艺设计拼音
        public List<CraftDesignItemDTO> craftDesignItemDTOList { get; set; } = new List<CraftDesignItemDTO>();
        public CraftDesignDTO()
        {

        }
        public CraftDesignDTO(String desc, List<CraftDesignItemDTO> craftDesignItemDTOList)
        {
            this.id = new FunctionHelper().Uuid;
            this.desc = desc;
            this.craftDesignItemDTOList = craftDesignItemDTOList;
        }
    }
    /// <summary>
    /// 工序和是否
    /// </summary>
    public class CraftDesignItemDTO
    {
        public String itemDesc { get; set; }//工序名称
        public Boolean check { get; set; }//是否
        public CraftDesignItemDTO(String itemDesc, Boolean check)
        {
            this.itemDesc = itemDesc;
            this.check = check;
        }
        public CraftDesignItemDTO()
        {

        }
    }

    /// <summary>
    /// 设计点位置
    /// </summary>
    public class GarmentPartDTO
    {
        public String id { get; set; }//id
        public String partDesc { get; set; }//位置描述

        public GarmentPartDTO()
        {

        }
    }
    /// <summary>
    /// 设计点信息For数据库
    /// </summary>
    public class DesignOptionDTO
    {
        public int designId { get; set; }
        public String styleCategoryCd { get; set; }
        public String itemCategoryCd { get; set; }
        public String itemCd { get; set; }
        public String itemValue { get; set; }
        public int itemSort { get; set; }
        public String itemNameCn { get; set; }
        public String itemShortNameCn { get; set; }
        public String itemNameEn { get; set; }
        public String itemShortNameEn { get; set; }
        public String itemNameJp { get; set; }
        public String itemShortNameJp { get; set; }
        public Double itemCost { get; set; }
        public Double itemCostMtm { get; set; }
        public Double itemUnitCost { get; set; }
        public int itemNetSort { get; set; }
        public int itemCutParts { get; set; }
        public int fileId { get; set; }
        public int havetoFlag { get; set; }
        public String remarks { get; set; }
        public int enableFlag { get; set; }
        public int deleteFlag { get; set; }
        public int version { get; set; }
        public DateTime createDate { get; set; }
        public DateTime updateDate { get; set; }
        public int createUser { get; set; }
        public int updateUser { get; set; }

        public DesignOptionDTO()
        {

        }
    }
    /// <summary>
    /// 外观设计点
    /// </summary>
    public class CraftFacadeDesignDTO
    {
        public String id { get; set; }
        public String partId { get; set; }  //  部位id
        public String partDesc { get; set; }   //  部位描述
        public String facadeCode { get; set; }  //  外观设计编码
        public int designId { get; set; }    //  设计点主键
        public String facadeValue { get; set; } //  设计点名称
        public String imageFilePath { get; set; }   //  图片路径
        public List<CraftDesignItemDTO> craftDesignItemDTOList { get; set; } = new List<CraftDesignItemDTO>();
        public CraftFacadeDesignDTO()
        {

        }
    }
    /// <summary>
    /// 款号和销量
    /// </summary>
    public class styleSaleCountDTO
    {
        public String styleCode { get; set; }
        public String count { get; set; }
        public styleSaleCountDTO()
        {

        }
        public styleSaleCountDTO(KeyValuePair<String, int> keyValuePair)
        {
            this.styleCode = keyValuePair.Key;
            this.count = keyValuePair.Value.ToString();
        }
    }
    /// <summary>
    /// 款式加外观Model
    /// </summary>
    public class Model款式加外观
    {
        public CraftDesignDTO craftDesignDTO { get; set; } = new CraftDesignDTO();//工艺设计知识库
        public List<FacadeDesignVO> facadeDesignVOs { get; set; } = new List<FacadeDesignVO>();//选中是设计点文件
        public List<String> filePictureNames { get; set; } = new List<String>();//图片名称不带扩展名设计点名称
        public List<FacadeDesignVO> newFacadeDesignVOs { get; set; } = new List<FacadeDesignVO>();
        public Model款式加外观(FileInfo[] files)
        {
            foreach (FileInfo file in files)
            {
                this.facadeDesignVOs.Add(
                    new FacadeDesignVO(
                            Path.GetFileNameWithoutExtension(file.Name),
                            file.FullName,
                            Image.FromFile(file.FullName)
                            )
                        );
                this.filePictureNames.Add(Path.GetFileNameWithoutExtension(file.Name));
            }

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="lists"></param>
        /// <returns></returns>
        public Model款式加外观 build未匹配(List<String> lists)
        {
            foreach (FacadeDesignVO item in this.facadeDesignVOs)
            {
                if (lists.Contains(item.facadeValue))
                {
                    this.newFacadeDesignVOs.Add(item);
                }
            }
            return this;
        }
        public Model款式加外观(List<CraftDesignDTO> craftDesignDTOs, String id)
        {
            foreach (CraftDesignDTO item in craftDesignDTOs)
            {
                if (id.Equals(item.id))
                {
                    this.craftDesignDTO = item;
                    return;
                }
            }
        }
    }
    /// <summary>
    /// 设计点文件
    /// </summary>
    public class FacadeDesignVO
    {
        public String facadeValue { get; set; } // 设计点名称
        public String facadeFileName { get; set; } // 设计点图片绝对路径带扩展名
        public Image facadePicture { get; set; } // 设计点图片
        public FacadeDesignVO()
        {

        }

        public FacadeDesignVO(string facadeValue, string facadeFileName, Image facadePicture)
        {
            this.facadeValue = facadeValue;
            this.facadeFileName = facadeFileName;
            this.facadePicture = facadePicture;
        }
    }
}
